THOR

Created

Thor is the patch container file created and used by the Thor Patcher

Files are saved in little-endian.

Label Bytes Type Condition Description
signature 24 bytes char "ASSF (C) 2007 Aeomin DEV".
"ASSF" stands for "Aeomin simple structured formate"1.
mergeMode 1 byte ubyte Whether to merge the files into a GRF or store them in e.g. the data directory. Filesystem (0x00), GRF (0x01).
numFiles 4 bytes uint32 The number of files in this thor container.
containerMode 2 bytes uint16 Indicates if the thor container has a single file or multiple files. Depending on the mode the structure changes. Single file (0x21), Multiple files (0x30).
targetGRFNameLen 1 byte ubyte The length of the target grf name string that follows.
targetGRFName targetGRFNameLen char The name of the target GRF in which the files should be merged into (if mergeMode is GRF (0x01)).
filetableSizeCompressed 4 bytes int32 Multiple files ZLib compressed size of the filetable.
filetableOffset 4 bytes int32 Multiple files The absolute position of the compressed filetable.
filetableOffset 1 byte ubyte Single file Ignored.

Filetable

If the containerMode is Single file then there is no filetable and the file entry directly follows. Otherwise the filetable is compressed with zlib and must be decompressed first.

After decompression read the following entries numFiles times.

Label Bytes Type Condition Description
filenameLen 1 byte ubyte Length of the filename that follows.
filename filenameLen char Full filename.
flags 1 byte ubyte Flags of the file. Remove (0x01). If the remove flag is set the file should be deleted from the filesystem/grf.
offset 4 bytes uint32 not Remove (0x01) Data offset of the file inside the thor container.
sizeCompressed 4 bytes int32 not Remove (0x01) ZLib compressed filesize.
size 4 bytes int32 not Remove (0x01) Uncompressed filesize.

Single file

If the containerMode is Single file then instead of the filetable info the file is directly read.

Label Bytes Type Condition Description
sizeCompressed 4 bytes int32 ZLib compressed filesize.
size 4 bytes int32 Uncompressed filesize.
filenameLen 1 byte ubyte Length of the filename that follows.
filename filenameLen char Full filename.
data sizeCompressed ubyte ZLib compressed file data.

Unfortunately I am not aware of any official documentation of the file format. There exists a prototype of the original author Aeomin but it doesn't use the same format anymore. Luckily Tokeiburu open-sourced parts of his GRF Editor (source link at the end of the description or below) which supports the THOR format. Later on LinkZ created an open-source drop-in replacement for the Thor Patcher called rpatchur which also supports the format.